﻿using System;
using Reactor.ServiceGrid.Workflows.Contexts;
using Reactor.ServiceGrid.Workflows.Steps;
using Samurai.Wakizashi.Workflow;

namespace Reactor.ServiceGrid.Workflows
{
    public class ShutdownServiceWorkflow : SequentialWorkflow<ServiceCommandContext>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ShutdownServiceWorkflow"/> class.
        /// </summary>
        public ShutdownServiceWorkflow(ServiceIdentifier serviceIdentifier)
        {
            if (serviceIdentifier == null) throw new ArgumentNullException("serviceIdentifier");

            Context = new ServiceCommandContext { ServiceIdentifier = serviceIdentifier };
            RegisterStep(new StopExistingServiceIfNecessary());
        }
    }
}
